home *** CD-ROM | disk | FTP | other *** search
/ Macintosh Technology Seed 1996 September / Macintosh Technology Seed (September 1996) (CDRM1437020).ISO / pc / qd3d15d6 / 15d6_sdk.exe / QD3D Win32 1.5d6 / Interfaces / QD3DRenderer.h < prev    next >
C/C++ Source or Header  |  1996-08-21  |  52KB  |  1,536 lines

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DRenderer.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Renderer types and routines                                   **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1996 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #ifndef QD3DRenderer_h
  15. #define QD3DRenderer_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #include "QD3DView.h"
  22. #include "QD3DSet.h"
  23. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH  
  24. #include "Events.h"
  25. #endif /* WINDOW_SYSTEM_MACINTOSH */
  26. #if defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  27. #include "windows.h"
  28. #endif /* WINDOW_SYSTEM_WIN32 */
  29.  
  30. #if defined(THINK_C) || defined(__SC__)
  31.     #pragma options(!pack_enums, !align_arrays)
  32.     #pragma SC options align=power
  33. #elif defined(__MWERKS__)
  34.     #pragma enumsalwaysint on
  35.     #pragma align_array_members off
  36.     #pragma options align=native
  37. #elif defined(__PPCC__)
  38.     #pragma options align=power
  39. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  40.     #pragma options enum=int
  41. #endif
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif    /* __cplusplus */
  46.  
  47. /******************************************************************************
  48.  **                                                                             **
  49.  **                            User Interface Things                             **
  50.  **                                                                             **
  51.  *****************************************************************************/
  52.  
  53. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH  
  54. /*
  55.  *  A callback to an application's event handling code. This is needed to    
  56.  *  support movable modal dialogs. The dialog's event filter calls this      
  57.  *  callback with events it does not handle.                                 
  58.  *  If an application handles the event it should return kQ3True.            
  59.  *  If the application does not handle the event it must return kQ3False and 
  60.  *  the dialog's event filter will pass the event to the system unhandled.   
  61.  */
  62. typedef TQ3Boolean (*TQ3MacOSDialogEventHandler)( 
  63.     EventRecord     event);
  64.  
  65. typedef struct TQ3DialogAnchor {
  66.     TQ3MacOSDialogEventHandler clientEventHandler;
  67. } TQ3DialogAnchor;
  68.  
  69. #elif defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  70.  
  71. typedef struct TQ3DialogAnchor {
  72.     HWND ownerWindow;    
  73. } TQ3DialogAnchor;
  74.  
  75. #else /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  76.  
  77. typedef struct TQ3DialogAnchor {
  78.     char notUsed;  /* place holder */
  79. } TQ3DialogAnchor;
  80.  
  81. #endif /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  82.  
  83. /******************************************************************************
  84.  **                                                                             **
  85.  **                                Renderer Functions                             **
  86.  **                                                                             **
  87.  *****************************************************************************/
  88.  
  89. QD3D_EXPORT TQ3RendererObject Q3Renderer_NewFromType(
  90.     TQ3ObjectType            rendererObjectType);
  91.  
  92. QD3D_EXPORT TQ3ObjectType Q3Renderer_GetType(
  93.     TQ3RendererObject        renderer);
  94.  
  95. /*
  96.  *    A bit set in this flag to indicates supported features
  97.  */
  98. #define kQ3RendererFeatureNone                            (0)            /* Implements nothing */
  99. #define kQ3RendererFeatureFlagHiddenSurfaceRemoval        (1U << 0)    /* Supports hidden surface removal */
  100. #define kQ3RendererFeatureFlagHiddenSurfaceRemovalDeep    (1U << 1)    /* >= 24 bit hidden surface removal precision */
  101. #define kQ3RendererFeatureFlagTexture                    (1U << 2)    /* Textures */
  102. #define kQ3RendererFeatureFlagTextureHighQuality        (1U << 3)    /* High-quality Textures (tri-linear or better) */
  103. #define kQ3RendererFeatureFlagTextureColor                (1U << 4)    /* Full color modulation and highlight of textures */
  104. #define kQ3RendererFeatureFlagTransparency                (1U << 5)    /* Transparency with RGB blending */
  105. #define kQ3RendererFeatureFlagTransparencyAlpha            (1U << 6)    /* Transparency with alpha blending */
  106. #define kQ3RendererFeatureFlagAntialiasing                (1U << 7)    /* AntiAliasing */
  107. #define kQ3RendererFeatureFlagShadows                    (1U << 8)    /* Shadows */
  108.  
  109. typedef unsigned long    TQ3RendererFeatureFlags;
  110.  
  111. /*
  112.  *    Q3Renderer_GetEditFeatures
  113.  *        Returns a mask of variable features in the renderer. A 1 bit does not 
  114.  *        indicate that this feature is currently "on", only that it is editable.
  115.  *        
  116.  *        You may "set" or "unset" these features using Q3Renderer_SetFeatures.
  117.  */
  118. QD3D_EXPORT TQ3Status Q3Renderer_GetEditFeatures(
  119.     TQ3RendererObject            renderer,
  120.     TQ3RendererFeatureFlags        *editableFlags);
  121.  
  122. /*
  123.  *    Q3Renderer_GetFeatures
  124.  *        Returns a mask of currently set features in the renderer. A 1 bit 
  125.  *        indicates that this feature is currently "on". Some features may be 
  126.  *        available but not turned on. Some features may be on (always), but 
  127.  *        not editable.
  128.  *
  129.  *    To get a complete mask of all available features, do:
  130.  *    
  131.  *        Q3Renderer_GetEditFeatures(renderer, &editable);
  132.  *        Q3Renderer_GetFeatures(renderer, &features);
  133.  *        totalFeatures = editable | features;
  134.  */
  135. QD3D_EXPORT TQ3Status Q3Renderer_GetFeatures(
  136.     TQ3RendererObject            renderer,
  137.     TQ3RendererFeatureFlags        *flags);
  138.  
  139. /*
  140.  *    Q3Renderer_SetFeatures
  141.  *        Turn on or off editable features in a renderer. 
  142.  *        Operation is:
  143.  *            newRendererFlags = 
  144.  *                (oldRendererFlags & ~editableFlags) |
  145.  *                (flags & editableFlags); 
  146.  */
  147. QD3D_EXPORT TQ3Status Q3Renderer_SetFeatures(
  148.     TQ3RendererObject            renderer,
  149.     TQ3RendererFeatureFlags        flags);
  150.  
  151.  
  152. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  153.  
  154. /*
  155.  *    Non-blocking, flush all buffered graphics to rasterizer. May or
  156.  *    may not update the draw context.
  157.  *    
  158.  *    This function has been replaced by Q3View_Flush
  159.  */
  160. QD3D_EXPORT TQ3Status Q3Renderer_Flush(
  161.     TQ3RendererObject        renderer,
  162.     TQ3ViewObject            view);
  163.     
  164. /*
  165.  *    Blocking, flush all buffered graphics to rasterizer and update
  166.  *    draw context.
  167.  *    
  168.  *    This function has been replaced by Q3View_Sync
  169.  */
  170. QD3D_EXPORT TQ3Status Q3Renderer_Sync(
  171.     TQ3RendererObject        renderer,
  172.     TQ3ViewObject            view);
  173.     
  174. #endif  /*  QD3D_OBSOLETE  */
  175.  
  176. /*
  177.  *    Q3Renderer_HasModalConfigure
  178.  *        Determine if this renderer has a modal settings dialog.
  179.  *
  180.  *    Q3Renderer_ModalConfigure
  181.  *        Have the renderer pop up a modal dialog box to configure its settings.
  182.  *    dialogAnchor - is platform specific data passed by the client to support
  183.  *      movable modal dialogs. 
  184.  *    MacOS: this is a callback to the calling application's event handler.
  185.  *      The renderer calls this function with events not handled by the 
  186.  *      settings dialog. This is necessary in order to support movable modal 
  187.  *      dialogs. An application's event handler must return kQ3True if it 
  188.  *      handles the event passed to the callback or kQ3False if not. 
  189.  *      An application which doesn't want to support a movable modal configure
  190.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  191.  *    Win32: this is the HWND of the owning window (typically an application's
  192.  *      main window).
  193.  *  canceled - returns a boolean inditacating that the user canceled the 
  194.  *    dialog.
  195.  *      
  196.  */
  197. QD3D_EXPORT TQ3Boolean Q3Renderer_HasModalConfigure(
  198.     TQ3RendererObject        renderer);
  199.  
  200. QD3D_EXPORT TQ3Status Q3Renderer_ModalConfigure(
  201.     TQ3RendererObject        renderer, 
  202.     TQ3DialogAnchor         dialogAnchor, 
  203.     TQ3Boolean                *canceled);
  204.  
  205. /*
  206.  *    Q3Renderer_GetPrivateData
  207.  *        Allows an application to collect private renderer configuration data
  208.  *      which it will then save. For example in a preference file or in a 
  209.  *        style template. An application should tag this data with the 
  210.  *        Renderer's object  name.
  211.  *    
  212.  *        if dataBuffer is NULL actualDataSize returns the required size in 
  213.  *        bytes of a data buffer large enough to store private data. 
  214.  *
  215.  *      bufferSize in the actual size of the memory block pointed to by 
  216.  *        dataBuffer
  217.  *
  218.  *        actualDataSize - on return the actual number of bytes written to the 
  219.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  220.  * 
  221.  */
  222.  
  223. QD3D_EXPORT TQ3Status Q3Renderer_GetPrivateData(
  224.     TQ3RendererObject        renderer, 
  225.     unsigned char            *dataBuffer, 
  226.     unsigned long            bufferSize,
  227.     unsigned long            *actualDataSize);
  228.  
  229. QD3D_EXPORT TQ3Status Q3Renderer_SetPrivateData(
  230.     TQ3RendererObject        renderer, 
  231.     unsigned char            *dataBuffer, 
  232.     unsigned long            bufferSize);
  233.  
  234. #if defined(ESCHER_VER_FUTURE) && ESCHER_VER_FUTURE
  235. /*
  236.  *    Q3Renderer_DeleteCaches
  237.  *    
  238.  *    Deletes any caches in a renderer created with 
  239.  *    Q3View_BeginRendererCache and Q3View_EndRendererCache that may be 
  240.  *    associated with this renderer.
  241.  */
  242. QD3D_EXPORT TQ3Status Q3Renderer_DeleteCaches(
  243.     TQ3RendererObject        renderer);
  244.  
  245. #endif  /*  ESCHER_VER_FUTURE  */
  246.  
  247. /******************************************************************************
  248.  **                                                                             **
  249.  **                        Interactive Renderer Specific Functions                 **
  250.  **                                                                             **
  251.  *****************************************************************************/
  252.  
  253. /* 
  254.  *  CSG IDs attribute 
  255.  */
  256. #define kQ3AttributeTypeConstructiveSolidGeometryID \
  257.     Q3_OBJECT_TYPE('c','s','g','i')
  258.  
  259. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  260. #define kQ3AttributeType_ConstructiveSolidGeometryID \
  261.     kQ3AttributeTypeConstructiveSolidGeometryID
  262. #endif  /*  QD3D_OBSOLETE  */
  263.  
  264. /* 
  265.  *  Object IDs, to be applied as attributes on geometries 
  266.  */
  267. #define kQ3SolidGeometryObjA    0
  268. #define kQ3SolidGeometryObjB    1
  269. #define kQ3SolidGeometryObjC    2
  270. #define kQ3SolidGeometryObjD    3
  271. #define kQ3SolidGeometryObjE    4
  272.  
  273. /* 
  274.  *  Possible CSG equations 
  275.  */
  276. typedef enum TQ3CSGEquation {
  277.     kQ3CSGEquationAandB            = (int)0x88888888,
  278.     kQ3CSGEquationAandnotB         = 0x22222222,
  279.     kQ3CSGEquationAanBonCad        = 0x2F222F22,
  280.     kQ3CSGEquationnotAandB        = 0x44444444,
  281.     kQ3CSGEquationnAaBorCanB    = 0x74747474
  282. } TQ3CSGEquation;
  283.  
  284. typedef enum TQ3HiddenSurfaceRemovalMode {
  285.     kQ3HiddenSurfaceRemovalMode_None,
  286.     kQ3HiddenSurfaceRemovalMode_Shallow,
  287.     kQ3HiddenSurfaceRemovalMode_Deep
  288. } TQ3HiddenSurfaceRemovalMode;
  289.  
  290. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_SetCSGEquation(
  291.     TQ3RendererObject        renderer,
  292.     TQ3CSGEquation            equation);
  293.  
  294. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_GetCSGEquation(
  295.     TQ3RendererObject        renderer,
  296.     TQ3CSGEquation            *equation);
  297.  
  298. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_SetPreferences(
  299.     TQ3RendererObject        renderer,
  300.     long                    vendorID,
  301.     long                    engineID);
  302.  
  303. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_GetPreferences(
  304.     TQ3RendererObject        renderer,
  305.     long                    *vendorID,
  306.     long                    *engineID);
  307.     
  308. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_SetDoubleBufferBypass(
  309.     TQ3RendererObject        renderer,
  310.     TQ3Boolean                bypass);
  311.  
  312. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_GetDoubleBufferBypass(
  313.     TQ3RendererObject        renderer,
  314.     TQ3Boolean                *bypass);
  315.  
  316. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_SetHiddenSurfaceRemovalMode(
  317.     TQ3RendererObject            renderer,
  318.     TQ3HiddenSurfaceRemovalMode    hiddenSurfaceRemovalMode);
  319.  
  320. QD3D_EXPORT TQ3Status Q3InteractiveRenderer_GetHiddenSurfaceRemovalMode(
  321.     TQ3RendererObject            renderer,
  322.     TQ3HiddenSurfaceRemovalMode    *hiddenSurfaceRemovalMode);
  323.  
  324.  
  325. /******************************************************************************
  326.  **                                                                             **
  327.  **                            Plug-in Renderer API                             **
  328.  **                                                                             **
  329.  *****************************************************************************/
  330.  
  331. /*
  332.  *    These bits should be set in the flag to indicate class supported
  333. */
  334. #define kQ3XRendererClassSupportNone                (0)            /* nothing */
  335. #define kQ3XRendererClassSupportFlagDoubleBuffer    (1U << 0)    /* Handle Double buffering */
  336. #define kQ3XRendererClassSupportFlagClearBuffer        (1U << 1)    /* Handle DrawContext clearing */
  337.  
  338. typedef unsigned long TQ3XRendererClassSupportFlags;
  339.  
  340. /*
  341.  *    Registration
  342.  */
  343. QD3D_EXPORT TQ3XObjectClass Q3XRendererClass_Register(
  344.     TQ3ObjectType        objectType,
  345.     char                *rendererName,
  346.     TQ3XMetaHandler        metaHandler,
  347.     unsigned long        sizeofClassPrivate,
  348.     unsigned long        sizeofDataPrivate);
  349.  
  350.  
  351. /******************************************************************************
  352.  **                                                                             **
  353.  **                            Renderer View Tools                                 **
  354.  **                                                                             **
  355.  **                    You may only call these methods from a plug-in             **
  356.  **                                                                             **
  357.  *****************************************************************************/
  358.  
  359. /*
  360.  *    Call by a renderer to call the user "idle" method, with progress 
  361.  *    information.
  362.  *    
  363.  *    Pass in (view, 0, n) on first call
  364.  *    Pass in (view, 1..n-1, n) during rendering
  365.  *    Pass in (view, n, n) upon completion
  366.  *    
  367.  *    Note: The user must have supplied an idleProgress method with 
  368.  *    Q3XView_SetIdleProgressMethod. Otherwise, the generic idle method is
  369.  *    called with no progress data. e.g. the Q3View_SetIdleMethod method
  370.  *    is called instead. (current and final are ignored, essentially.)
  371.  *
  372.  *    Returns kQ3Failure if rendering is cancelled.
  373.  */
  374. QD3D_EXPORT TQ3Status Q3XView_IdleProgress(
  375.      TQ3ViewObject        view,
  376.      unsigned long        current,
  377.      unsigned long        completed);
  378.  
  379. /*
  380.  *    Called by an asynchronous renderer when it completes a frame.
  381.  */
  382. QD3D_EXPORT TQ3Status Q3XView_EndFrame(
  383.      TQ3ViewObject        view);
  384.  
  385. /******************************************************************************
  386.  **                                                                             **
  387.  **                            Renderer AttributeSet Tools                         **
  388.  **                                                                             **
  389.  **                    You may only call these methods from a plug-in             **
  390.  **                                                                             **
  391.  *****************************************************************************/
  392.  
  393. /*
  394.  *    Faster access to geometry attribute sets.
  395.  *    
  396.  *    Returns pointer to INTERNAL data structure for elements and attributes
  397.  *    in an attributeSet, or NULL if no attribute exists.
  398.  *    
  399.  *    For attributes of type kQ3AttributeType..., the internal data structure
  400.  *    is identical to the data structure used in Q3AttributeSet_Add.
  401.  */
  402. QD3D_EXPORT void *Q3XAttributeSet_GetPointer(
  403.      TQ3AttributeSet            attributeSet,
  404.      TQ3AttributeType        attributeType);
  405.      
  406. #define kQ3XAttributeMaskNone                        \
  407.     0L
  408.  
  409. #define kQ3XAttributeMaskSurfaceUV                    \
  410.     (1 << (kQ3AttributeTypeSurfaceUV - 1))
  411.  
  412. #define kQ3XAttributeMaskShadingUV                    \
  413.     (1 << (kQ3AttributeTypeShadingUV - 1))
  414.  
  415. #define kQ3XAttributeMaskNormal                        \
  416.     (1 << (kQ3AttributeTypeNormal - 1))
  417.  
  418. #define kQ3XAttributeMaskAmbientCoefficient            \
  419.     (1 << (kQ3AttributeTypeAmbientCoefficient - 1))
  420.  
  421. #define kQ3XAttributeMaskDiffuseColor                \
  422.     (1 << (kQ3AttributeTypeDiffuseColor - 1))
  423.  
  424. #define kQ3XAttributeMaskSpecularColor                \
  425.     (1 << (kQ3AttributeTypeSpecularColor - 1))
  426.  
  427. #define kQ3XAttributeMaskSpecularControl            \
  428.     (1 << (kQ3AttributeTypeSpecularControl - 1))
  429.  
  430. #define kQ3XAttributeMaskTransparencyColor            \
  431.     (1 << (kQ3AttributeTypeTransparencyColor - 1))
  432.  
  433. #define kQ3XAttributeMaskSurfaceTangent                \
  434.     (1 << (kQ3AttributeTypeSurfaceTangent - 1))
  435.  
  436. #define kQ3XAttributeMaskHighlightState                \
  437.     (1 << (kQ3AttributeTypeHighlightState - 1))
  438.  
  439. #define kQ3XAttributeMaskSurfaceShader                \
  440.     (1 << (kQ3AttributeTypeSurfaceShader - 1))
  441.  
  442. #define kQ3XAttributeMaskCustomAttribute            0x80
  443.  
  444. #define kQ3XAttributeMaskAll                        \
  445.     (                                                 \
  446.         kQ3XAttributeMaskSurfaceUV             |         \
  447.         kQ3XAttributeMaskShadingUV             |         \
  448.         kQ3XAttributeMaskNormal             |         \
  449.         kQ3XAttributeMaskAmbientCoefficient |         \
  450.         kQ3XAttributeMaskDiffuseColor         |         \
  451.         kQ3XAttributeMaskSpecularColor         |         \
  452.         kQ3XAttributeMaskSpecularControl     |         \
  453.         kQ3XAttributeMaskTransparencyColor     |         \
  454.         kQ3XAttributeMaskSurfaceTangent     |         \
  455.         kQ3XAttributeMaskHighlightState        |        \
  456.         kQ3XAttributeMaskSurfaceShader        |        \
  457.         kQ3XAttributeMaskCustomAttribute            \
  458.     )
  459.  
  460. #define kQ3XAttributeMaskInherited                    \
  461.     (                                                 \
  462.         kQ3XAttributeMaskSurfaceUV             |         \
  463.         kQ3XAttributeMaskShadingUV             |         \
  464.         kQ3XAttributeMaskNormal             |         \
  465.         kQ3XAttributeMaskAmbientCoefficient |        \
  466.         kQ3XAttributeMaskDiffuseColor         |         \
  467.         kQ3XAttributeMaskSpecularColor         |         \
  468.         kQ3XAttributeMaskSpecularControl     |         \
  469.         kQ3XAttributeMaskTransparencyColor     |         \
  470.         kQ3XAttributeMaskSurfaceTangent     |         \
  471.         kQ3XAttributeMaskHighlightState             \
  472.     )
  473.  
  474. #define kQ3XAttributeMaskInterpolated                \
  475.     (                                                 \
  476.         kQ3XAttributeMaskSurfaceUV             |         \
  477.         kQ3XAttributeMaskShadingUV             |         \
  478.         kQ3XAttributeMaskNormal             |         \
  479.         kQ3XAttributeMaskAmbientCoefficient |         \
  480.         kQ3XAttributeMaskDiffuseColor         |         \
  481.         kQ3XAttributeMaskSpecularColor         |         \
  482.         kQ3XAttributeMaskSpecularControl     |         \
  483.         kQ3XAttributeMaskTransparencyColor     |         \
  484.         kQ3XAttributeMaskSurfaceTangent     |         \
  485.     )
  486.  
  487. typedef unsigned long TQ3XAttributeMask;
  488.  
  489. QD3D_EXPORT TQ3XAttributeMask Q3XAttributeSet_GetMask(
  490.     TQ3AttributeSet            attributeSet);
  491.  
  492. /******************************************************************************
  493.  **                                                                             **
  494.  **                            Renderer Draw Context Tools                         **
  495.  **                                                                             **
  496.  *****************************************************************************/
  497.  
  498. typedef struct TQ3XDrawRegionPrivate    *TQ3XDrawRegion;
  499.  
  500. QD3D_EXPORT TQ3Status Q3XDrawContext_GetDrawRegion(
  501.     TQ3DrawContextObject    drawContext,
  502.     TQ3XDrawRegion            *drawRegion);
  503.  
  504. typedef enum TQ3XDrawContextValidationMasks {
  505.     kQ3XDrawContextValidationClearFlags            =    0x00000000L,
  506.  
  507.     kQ3XDrawContextValidationDoubleBuffer        =    1 << 0,
  508.     kQ3XDrawContextValidationShader                =    1 << 1,
  509.     kQ3XDrawContextValidationClearFunction        =    1 << 2,
  510.     kQ3XDrawContextValidationActiveBuffer        =    1 << 3,
  511.     kQ3XDrawContextValidationInternalOffScreen    =    1 << 4,
  512.     kQ3XDrawContextValidationPane                =    1 << 5,
  513.     kQ3XDrawContextValidationMask                =    1 << 6,
  514.     kQ3XDrawContextValidationDevice                =    1 << 7,
  515.     kQ3XDrawContextValidationWindow                =    1 << 8,
  516.     kQ3XDrawContextValidationWindowSize            =    1 << 9,
  517.     kQ3XDrawContextValidationWindowClip            =    1 << 10,
  518.     kQ3XDrawContextValidationWindowPosition        =    1 << 11,
  519.     kQ3XDrawContextValidationPlatformAttributes    =    1 << 12,
  520.     kQ3XDrawContextValidationForegroundShader    =    1 << 13,
  521.     kQ3XDrawContextValidationBackgroundShader    =    1 << 14,
  522.     kQ3XDrawContextValidationAll                =    ~0
  523. } TQ3XDrawContextValidationMasks;
  524.  
  525. typedef unsigned long TQ3XDrawContextValidation;
  526.  
  527. QD3D_EXPORT TQ3Status Q3XDrawContext_ClearValidationFlags(
  528.     TQ3DrawContextObject        drawContext);
  529.  
  530. QD3D_EXPORT TQ3Status Q3XDrawContext_GetValidationFlags(
  531.     TQ3DrawContextObject        drawContext,
  532.     TQ3XDrawContextValidation    *validationFlags);
  533.  
  534.  
  535. /******************************************************************************
  536.  **                                                                             **
  537.  **                            Renderer Draw Region Tools                         **
  538.  **                                                                             **
  539.  *****************************************************************************/
  540.  
  541. typedef enum TQ3XClipMaskState {
  542.     kQ3XClipMaskFullyExposed,
  543.     kQ3XClipMaskPartiallyExposed,
  544.     kQ3XClipMaskNotExposed
  545. } TQ3XClipMaskState;
  546.  
  547. typedef struct TQ3XDrawRegionClipMask {
  548.     unsigned char        *image;
  549.     unsigned long        width;
  550.     unsigned long        height;
  551.     unsigned long        rowBytes;
  552.     TQ3Endian            bitOrder;
  553. } TQ3XDrawRegionClipMask;
  554.  
  555.  
  556. typedef struct TQ3XDrawRegionDescriptor {
  557.     unsigned long        width;
  558.     unsigned long        height;
  559.     unsigned long        rowBytes;
  560.     unsigned long        pixelSize;
  561.     TQ3PixelType        pixelType;
  562.     TQ3Endian            bitOrder;
  563.     TQ3Endian            byteOrder;
  564. } TQ3XDrawRegionDescriptor;
  565.  
  566.  
  567. typedef void (*TQ3XDrawRegionRendererPrivateDeleteMethod)(
  568.     void    *rendererPrivate);
  569.  
  570. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceScaleX( 
  571.     TQ3XDrawRegion     drawRegion,
  572.     float            *deviceScaleX);
  573.  
  574. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceScaleY( 
  575.     TQ3XDrawRegion     drawRegion,
  576.     float            *deviceScaleY);
  577.  
  578.  
  579. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceOffsetX( 
  580.     TQ3XDrawRegion     drawRegion,
  581.     float            *deviceOffsetX);
  582.  
  583. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceOffsetY( 
  584.     TQ3XDrawRegion     drawRegion,
  585.     float            *deviceOffsetX);
  586.  
  587.  
  588. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetWindowScaleX( 
  589.     TQ3XDrawRegion     drawRegion,
  590.     float            *windowScaleX);
  591.  
  592. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetWindowScaleY( 
  593.     TQ3XDrawRegion     drawRegion,
  594.     float            *windowScaleY);
  595.  
  596.  
  597. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetWindowOffsetX( 
  598.     TQ3XDrawRegion     drawRegion,
  599.     float            *windowOffsetX);
  600.  
  601. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetWindowOffsetY( 
  602.     TQ3XDrawRegion     drawRegion,
  603.     float            *windowOffsetY);
  604.  
  605. QD3D_EXPORT TQ3Status Q3XDrawRegion_IsActive( 
  606.     TQ3XDrawRegion     drawRegion,
  607.     TQ3Boolean        *isActive);
  608.  
  609.  
  610. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetNextRegion( 
  611.     TQ3XDrawRegion     drawRegion,
  612.     TQ3XDrawRegion    *nextDrawRegion);
  613.  
  614.  
  615. QD3D_EXPORT TQ3Status Q3XDrawRegion_Start( 
  616.     TQ3XDrawRegion    drawRegion, 
  617.     TQ3Boolean        clear);
  618.  
  619. QD3D_EXPORT TQ3Status Q3XDrawRegion_End( 
  620.     TQ3XDrawRegion     drawRegion);
  621.  
  622. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetDeviceTransform( 
  623.     TQ3XDrawRegion     drawRegion,
  624.     TQ3Matrix4x4    **deviceTransform);
  625.  
  626. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetClipFlags( 
  627.     TQ3XDrawRegion         drawRegion,
  628.     TQ3XClipMaskState    *clipMaskState);
  629.     
  630. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetClipMask( 
  631.     TQ3XDrawRegion             drawRegion,
  632.     TQ3XDrawRegionClipMask    **clipMask);
  633.     
  634. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  635.  
  636. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetClipRegion(
  637.     TQ3XDrawRegion    drawRegion,
  638.     RgnHandle        *rgnHandle);
  639.     
  640. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetGDHandle(
  641.     TQ3XDrawRegion    drawRegion,
  642.     GDHandle        *gdHandle);
  643.     
  644. #endif  /* WINDOW_SYSTEM_MACINTOSH  */     
  645.  
  646. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetRendererPrivate( 
  647.     TQ3XDrawRegion     drawRegion,
  648.     void            **rendererPrivate);
  649.  
  650. QD3D_EXPORT TQ3Status Q3XDrawRegion_SetRendererPrivate( 
  651.     TQ3XDrawRegion                                 drawRegion, 
  652.     const void                                     *rendererPrivate,
  653.     TQ3XDrawRegionRendererPrivateDeleteMethod    deleteMethod);
  654.  
  655. QD3D_EXPORT TQ3Status Q3XDrawRegion_SetUseDefaultRendererFlag( 
  656.     TQ3XDrawRegion    drawRegion, 
  657.     TQ3Boolean         flag);
  658.  
  659. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetUseDefaultRendererFlag( 
  660.     TQ3XDrawRegion    drawRegion,
  661.     TQ3Boolean        *useDefaultRenderingFlag);
  662.  
  663. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetNativeDescriptor(
  664.     TQ3XDrawRegion                    drawRegion,
  665.     const TQ3XDrawRegionDescriptor    **descriptor);
  666.     
  667. QD3D_EXPORT TQ3Status Q3XDrawRegion_UseDescriptor(
  668.     TQ3XDrawRegion                    drawRegion,
  669.     const TQ3XDrawRegionDescriptor    *descriptor);
  670.  
  671. QD3D_EXPORT TQ3Status Q3XDrawRegion_GetImage(
  672.     TQ3XDrawRegion            drawRegion,
  673.     void                    **image);
  674.     
  675. QD3D_EXPORT TQ3Status Q3XDrawRegion_LookupColor(
  676.     TQ3XDrawRegion    drawRegion,
  677.     float            red,
  678.     float            green,
  679.     float            blue,
  680.     float            alpha,
  681.     unsigned long    *pixelValue);
  682.  
  683. QD3D_EXPORT TQ3Status Q3XDrawRegion_PutPixel(
  684.     TQ3XDrawRegion    drawRegion,
  685.     unsigned long    x,
  686.     unsigned long    y,
  687.     float            red,
  688.     float            green,
  689.     float            blue,
  690.     float            alpha);
  691.     
  692. QD3D_EXPORT TQ3Status Q3XDrawRegion_PutRaster(
  693.     TQ3XDrawRegion        drawRegion,
  694.     unsigned long        x,
  695.     unsigned long        y,
  696.     unsigned long        width,
  697.     unsigned long        height,
  698.     const TQ3ColorARGB    *raster);
  699.  
  700. /******************************************************************************
  701.  **                                                                             **
  702.  **                            Renderer Class Methods                             **
  703.  **                                                                             **
  704.  *****************************************************************************/
  705. /*
  706.  *    Methods from Object
  707.  *        kQ3XMethodTypeObjectClassRegister
  708.  *        kQ3XMethodTypeObjectClassUnregister
  709.  *        kQ3XMethodTypeObjectNew
  710.  *        kQ3XMethodTypeObjectDelete
  711.  *        kQ3XMethodTypeObjectRead
  712.  *        kQ3XMethodTypeObjectTraverse
  713.  *        kQ3XMethodTypeObjectWrite
  714.  *        
  715.  *    Methods from Shared
  716.  *        kQ3MethodTypeSharedEdited
  717.  *
  718.  *    Renderer Methods
  719.  *    
  720.  *    The renderer methods should be implemented according to the type
  721.  *    of renderer being written.
  722.  *
  723.  *    For the purposes of documentation, there are two basic types of
  724.  *    renderers: 
  725.  *
  726.  *        Interactive
  727.  *            Interactive Renderer
  728.  *            WireFrame Renderer
  729.  *        
  730.  *        Deferred
  731.  *            a ray-tracer
  732.  *            painter's algorithm renderer (cached in a BSP triangle tree)
  733.  *            an artistic renderer (simulates a pencil drawing, etc.)
  734.  *
  735.  *    The main difference is how each renderer handles incoming state and 
  736.  *    geometry.
  737.  *
  738.  *    An interactive renderer immediately transforms, culls, and shades
  739.  *    incoming geometry and performs rasterization. For example, in a 
  740.  *    single-buffered WireFrame renderer, you will see a new triangle
  741.  *    immediately after Q3Triangle_Draw (if it's visible, of course).
  742.  *
  743.  *    A deferred renderer caches the view state and each geometry, 
  744.  *    converting into any internal queue of drawing commands. Rasterization
  745.  *    is not actually performed until all data has been submitted.
  746.  *    
  747.  *    For example, a ray-tracer may not rasterize anything until the
  748.  *    end of the rendering loop, or until an EndFrame call is made.
  749.  */
  750.  
  751. /******************************************************************************
  752.  **                                                                             **
  753.  **                            Renderer Support Flags                             **
  754.  **                                                                             **
  755.  *****************************************************************************/
  756. /*
  757.  *    kQ3XMethodTypeRendererClassSupportFlag
  758.  *    TQ3XRendererClassSupportFlagMethod
  759.  *    
  760.  *    Return the TQ3XRendererClassSupportFlags for your renderer class. 
  761.  *
  762.  *    kQ3XRendererClassSupportFlagDoubleBuffer    
  763.  *        - the drawContext will not allocate or manage a back image buffer
  764.  *        - you must update the front buffer
  765.  *    kQ3XRendererClassSupportFlagClearBuffer
  766.  *        - the drawContext will not be cleared before startFrame
  767.  *        - you must clear the image buffer with the desired drawcontext
  768.  *            method.
  769.  *
  770.  *    If no method is supplied, the default is 0L.
  771.  *    
  772.  *    OPTIONAL
  773.  */
  774. #define kQ3XMethodTypeRendererClassSupportFlag \
  775.     Q3_METHOD_TYPE('r','d','s','f')
  776. typedef TQ3XRendererClassSupportFlags TQ3XRendererClassSupportFlagMethod;
  777.  
  778. /*
  779.  *    kQ3XMethodTypeRendererGetEditFeatures
  780.  *    TQ3XRendererGetEditFeaturesMethod
  781.  *    
  782.  *    Return the TQ3RendererFeatureFlags of the editable features of your 
  783.  *    renderer. 
  784.  *
  785.  *    If no method is supplied, or the kQ3MethodTypeRendererSetFeatures is
  786.  *    NULL, the default editableFlags is kQ3RendererFeatureNone.
  787.  *    
  788.  *    OPTIONAL
  789.  */
  790. #define kQ3XMethodTypeRendererGetEditFeatures \
  791.     Q3_METHOD_TYPE('r','d','f','e')
  792. typedef TQ3Status (*TQ3XRendererGetEditFeaturesMethod)(
  793.     TQ3RendererObject            renderer,
  794.     void                        *rendererPrivate,
  795.     TQ3RendererFeatureFlags        *editableFlags);
  796.  
  797. /*
  798.  *    kQ3MethodTypeRendererGetFeatures
  799.  *    TQ3XRendererGetFeaturesMethod
  800.  *    
  801.  *    Return the TQ3XRendererFeatureFlags of the current features set in
  802.  *    your renderer. 
  803.  *
  804.  *    If no method is supplied, the default flags is kQ3RendererFeatureNone.
  805.  *    
  806.  *    OPTIONAL
  807.  */
  808. #define kQ3XMethodTypeRendererGetFeatures \
  809.     Q3_METHOD_TYPE('r','d','f','g')
  810. typedef TQ3Status (*TQ3XRendererGetFeaturesMethod)(
  811.     TQ3RendererObject            renderer,
  812.     void                        *rendererPrivate,
  813.     TQ3RendererFeatureFlags        *flags);
  814.  
  815. /*
  816.  *    kQ3XMethodTypeRendererSetFeatures
  817.  *    TQ3XRendererSetFeaturesMethod
  818.  *    
  819.  *    Set the TQ3RendererFeatureFlags in the current features set of
  820.  *    your renderer. 
  821.  *
  822.  *    Operation is:
  823.  *        newRendererFlags = 
  824.  *            (oldRendererFlags & ~editableFlags) |
  825.  *            (flags & editableFlags); 
  826.  *
  827.  *    If no method is supplied, the Q3Renderer_GetEditFeatures always returns
  828.  *    kQ3RendererFeatureNone.
  829.  *    
  830.  *    OPTIONAL
  831.  */
  832. #define kQ3XMethodTypeRendererSetFeatures \
  833.     Q3_METHOD_TYPE('r','d','f','s')
  834. typedef TQ3Status (*TQ3XRendererSetFeaturesMethod)(
  835.     TQ3RendererObject            renderer,
  836.     void                        *rendererPrivate,
  837.     TQ3RendererFeatureFlags        flags);
  838.     
  839. /******************************************************************************
  840.  **                                                                             **
  841.  **                        Renderer User Interface Methods                         **
  842.  **                                                                             **
  843.  *****************************************************************************/
  844.  
  845. /*
  846.  *    TQ3XRendererModalConfigureMethod
  847.  *    
  848.  *    This method should pop up a modal dialog to edit the renderer settings 
  849.  *    found in the renderer private. 
  850.  *    
  851.  *    dialogAnchor - is platform specific data passed by the client to support
  852.  *      movable modal dialogs. 
  853.  *    MacOS: this is a callback to the calling application's event handler.
  854.  *      The renderer calls this function with events not handled by the 
  855.  *      settings dialog. This is necessary in order to support movable modal 
  856.  *      dialogs. An application's event handler must return kQ3True if it 
  857.  *      handles the event passed to the callback or kQ3False if not. 
  858.  *      An application which doesn't want to support a movable modal configure
  859.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  860.  *      A renderer should implement a non-movable style dialog in that case.
  861.  *    Win32: this is the HWND of the owning window (typically an application's
  862.  *      main window).  (Win32 application modal dialogs are always movable.)
  863.  *  canceled - returns a boolean inditacating that the user canceled the 
  864.  *    dialog.
  865.  *    
  866.  *    OPTIONAL
  867.  */
  868. #define kQ3XMethodTypeRendererModalConfigure \
  869.     Q3_METHOD_TYPE('r','d','m','c')    
  870. typedef TQ3Status (*TQ3XRendererModalConfigureMethod)(
  871.     TQ3RendererObject            renderer,
  872.     TQ3DialogAnchor             dialogAnchor, 
  873.     TQ3Boolean                    *canceled,    
  874.     void                        *rendererPrivate);
  875.  
  876. /*
  877.  *    TQ3XRendererGetPrivateDataMethod
  878.  *    
  879.  *        Allows an application to collect private configuration data from the
  880.  *      renderer
  881.  *      which it will then save. For example in a preference file or in a 
  882.  *        style template. An application should tag this data with the 
  883.  *        Renderer's object name.
  884.  *    
  885.  *        if dataBuffer is NULL actualDataSize returns the required size in 
  886.  *        bytes of a data bufferlarge enough to store private data. 
  887.  *
  888.  *      bufferSize in the actual size of the memory block pointed to by 
  889.  *        dataBuffer
  890.  *
  891.  *        actualDataSize - on return the actual number of bytes written to the
  892.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  893.  *
  894.  *    OPTIONAL
  895.  */
  896. #define kQ3XMethodTypeRendererGetPrivateData \
  897.     Q3_METHOD_TYPE('r','d','g','p')    
  898. typedef TQ3Status (*TQ3XRendererGetPrivateDataMethod)(
  899.     TQ3RendererObject            renderer, 
  900.     unsigned char                *dataBuffer, 
  901.     unsigned long                bufferSize,
  902.     unsigned long                *actualDataSize,    
  903.     void                        *rendererPrivate);
  904.  
  905. /*
  906.  *    TQ3XRendererSetPrivateDataMethod
  907.  *    
  908.  *        Allows an application to pass private configuration data which has previously
  909.  *      been obtained from a renderer via Q3Renderer_GetPrivateData. For example in a 
  910.  *      preference file or in a style
  911.  *      template. An application should tag this data with the Renderer's object
  912.  *      name.
  913.  *    
  914.  *        if dataBuffer is NULL returns the required size in bytes of a data buffer
  915.  *        large enough to store private data. 
  916.  *
  917.  *      bufferSize in the actual size of the memory block pointed to by dataBuffer
  918.  *
  919.  *      if dataBuffer is not NULL the return value is the actual number of bytes
  920.  *      written to the dataBuffer.
  921.  *
  922.  *    OPTIONAL
  923.  */
  924. #define kQ3XMethodTypeRendererSetPrivateData \
  925.     Q3_METHOD_TYPE('r','d','s','p')    
  926. typedef TQ3Status (*TQ3XRendererSetPrivateDataMethod)(
  927.     TQ3RendererObject            renderer, 
  928.     unsigned char                *dataBuffer, 
  929.     unsigned long                bufferSize,    
  930.     void                        *rendererPrivate);
  931.  
  932. /******************************************************************************
  933.  **                                                                             **
  934.  **                        Renderer Drawing State Methods                         **
  935.  **                                                                             **
  936.  *****************************************************************************/
  937. /*
  938.  *    TQ3RendererStartFrame
  939.  *    
  940.  *    The StartFrame method is called first at Q3View_StartRendering
  941.  *    and should:
  942.  *        - initialize any renderer state to defaults
  943.  *        - extract any and all useful data from the drawContext
  944.  *
  945.  *    If your renderer passed in kQ3RendererFlagClearBuffer at 
  946.  *    registration, then it should also:
  947.  *        - clear the drawContext 
  948.  *    
  949.  *        When clearing, your renderer may opt to:
  950.  *        - NOT clear anything (if you touch every pixel, for example)
  951.  *        - to clear with your own routine, or
  952.  *        - to use the draw context default clear method by calling 
  953.  *        Q3DrawContext_Clear. Q3DrawContext_Clear takes advantage of
  954.  *        any available hardware in the system for clearing.
  955.  *    
  956.  *    This call also signals the start of all default submit commands from
  957.  *    the view. The renderer will receive updates for the default view
  958.  *    state via its Update methods before StartPass is called.
  959.  *    
  960.  *    REQUIRED
  961.  */
  962. #define kQ3XMethodTypeRendererStartFrame    \
  963.     Q3_METHOD_TYPE('r','d','c','l')
  964. typedef TQ3Status (*TQ3XRendererStartFrameMethod)(
  965.     TQ3ViewObject            view,
  966.     void                    *rendererPrivate,
  967.     TQ3DrawContextObject    drawContext);
  968.     
  969. /*
  970.  *    kQ3XMethodTypeRendererStartPass
  971.  *    TQ3XRendererStartPassMethod
  972.  *    
  973.  *    The StartPass method is called during Q3View_StartRendering but after
  974.  *    the StartFrame command. It should:
  975.  *        - collect camera and light information
  976.  *    
  977.  *    If your renderer supports deferred camera transformation, camera is the
  978.  *    main camera which will be submitted in the hierarchy somewhere. It
  979.  *    is never NULL.
  980.  *
  981.  *    If your renderer does not support deferred camera transformation, camera
  982.  *    is the transformed camera.
  983.  *
  984.  *    If your renderer supports deferred light transformation, lights will be
  985.  *    NULL, and will be submitted to your light draw methods instead.
  986.  *
  987.  *    This call signals the end of the default update state, and the start of submit
  988.  *    commands from the user to the view.
  989.  *
  990.  *    REQUIRED
  991.  */
  992. #define kQ3XMethodTypeRendererStartPass \
  993.     Q3_METHOD_TYPE('r','d','s','t')
  994. typedef TQ3Status (*TQ3XRendererStartPassMethod)(
  995.     TQ3ViewObject            view,
  996.     void                    *rendererPrivate,
  997.     TQ3CameraObject            camera,
  998.     TQ3GroupObject            lightGroup);
  999.  
  1000. /*
  1001.  *    kQ3XMethodTypeRendererFlushFrame
  1002.  *    TQ3XRendererFlushFrameMethod
  1003.  *    
  1004.  *    This call is only implemented by asynchronous renderers.
  1005.  *    
  1006.  *    The FlushFrame method is called between the StartPass and EndPass
  1007.  *    methods and is called when the user wishes to flush any asynchronous
  1008.  *    drawing tasks (which draw to the drawcontext), but does not want 
  1009.  *    to block.
  1010.  *    
  1011.  *    The result of this call is that an image should "eventually" appear
  1012.  *    asynchronously.
  1013.  *    
  1014.  *    For asynchronous rendering, this call is non-blocking.
  1015.  *    
  1016.  *    An interactive renderer should ensure that all received
  1017.  *    geometries are drawn in the image.
  1018.  *    
  1019.  *    An interactive renderer that talks to hardware should force
  1020.  *    the hardware to generate an image.
  1021.  *    
  1022.  *    A deferred renderer should exhibit a similar behaviour,
  1023.  *    though it is not required.  A deferred renderer should spawn
  1024.  *    a process that generates a partial image from the currently
  1025.  *    accumulated drawing state. 
  1026.  *    
  1027.  *    However, for renderers such as ray-tracers which generally are
  1028.  *    quite compute-intensive, FlushFrame is not required and is a no-op.
  1029.  *
  1030.  *    OPTIONAL
  1031.  */
  1032. #define kQ3XMethodTypeRendererFlushFrame    \
  1033.     Q3_METHOD_TYPE('r','d','f','l')
  1034. typedef TQ3Status (*TQ3XRendererFlushFrameMethod)(
  1035.     TQ3ViewObject            view,
  1036.     void                    *rendererPrivate,
  1037.     TQ3DrawContextObject    drawContext);
  1038.  
  1039. /*
  1040.  *    kQ3XMethodTypeRendererEndPass
  1041.  *    TQ3XRendererEndPassMethod
  1042.  *    
  1043.  *    The EndPass method is called at Q3View_EndRendering and signals
  1044.  *    the end of submit commands to the view.
  1045.  *
  1046.  *    If an error occurs, the renderer should call Q3XError_Post and
  1047.  *    return kQ3ViewStatusError.
  1048.  *    
  1049.  *    If a renderer requires another pass on the renderering data,
  1050.  *    it should return kQ3ViewStatusRetraverse.
  1051.  *    
  1052.  *    If rendering was cancelled, this function will not be called
  1053.  *    and the view will handle returning kQ3ViewStatusCancelled;
  1054.  *    
  1055.  *    Otherwise, your renderer should begin completing the process of 
  1056.  *    generating the image in the drawcontext. If you have buffered
  1057.  *    any drawing data, flush it. RendererEnd should have a similar
  1058.  *    effect as RendererFlushFrame.
  1059.  *    
  1060.  *    If the renderer is synchronous:
  1061.  *        - complete rendering of the entire frame
  1062.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer
  1063.  *            - Update the front buffer
  1064.  *        else
  1065.  *            - DrawContext will update the front buffer after returning
  1066.  *
  1067.  *    If the renderer is asynchronous
  1068.  *        - spawn rendering thread for entire frame
  1069.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer,
  1070.  *            - you must eventually update the front buffer asynchronously
  1071.  *        else
  1072.  *            - you must eventually update the back buffer asynchronously
  1073.  *            
  1074.  *    REQUIRED
  1075.  */
  1076. #define kQ3XMethodTypeRendererEndPass    \
  1077.     Q3_METHOD_TYPE('r','d','e','d')
  1078. typedef TQ3ViewStatus (*TQ3XRendererEndPassMethod)(
  1079.     TQ3ViewObject            view,
  1080.     void                    *rendererPrivate);
  1081.  
  1082. /*
  1083.  *    kQ3XMethodTypeRendererEndFrame
  1084.  *    TQ3XRendererEndFrame
  1085.  *    
  1086.  *    This call is only implemented by asynchronous renderers.
  1087.  *
  1088.  *    The EndFrame method is called from Q3View_Sync, which is
  1089.  *    called after Q3View_EndRendering and signals that the user
  1090.  *    wishes to see the completed image and is willing to block.
  1091.  *    
  1092.  *    If your renderer supports kQ3RendererFlagDoubleBuffer
  1093.  *        - update the front buffer completely 
  1094.  *    else
  1095.  *        - update the back buffer completely
  1096.  *
  1097.  *    This call is equivalent in functionality to RendererFlushFrame
  1098.  *    but blocks until the image is completed.
  1099.  *    
  1100.  *    If no method is supplied, the default is a no-op.
  1101.  *    
  1102.  *    NOTE: Registering a method of this type indicates that your renderer will
  1103.  *    be rendering after Q3View_EndRendering has been called.
  1104.  *    
  1105.  *    OPTIONAL
  1106.  */
  1107. #define kQ3XMethodTypeRendererEndFrame    \
  1108.     Q3_METHOD_TYPE('r','d','s','y')
  1109. typedef TQ3Status (*TQ3XRendererEndFrameMethod)(
  1110.     TQ3ViewObject            view,
  1111.     void                    *rendererPrivate,
  1112.     TQ3DrawContextObject    drawContext);
  1113.     
  1114. /*
  1115.  *    The RendererCancel method is called after Q3View_StartRendering
  1116.  *    and signals the termination of all rendering operations.
  1117.  *
  1118.  *    A renderer should clean up any cached data, and cancel all 
  1119.  *    rendering operations.
  1120.  *    
  1121.  *    If called before Q3View_EndRendering, the RendererEnd method
  1122.  *    is NOT called.
  1123.  *    
  1124.  *    If called after Q3View_EndRendering, the renderer should kill
  1125.  *    any threads and terminate any further rendering.
  1126.  *    
  1127.  *    REQUIRED
  1128.  */
  1129. #define kQ3XMethodTypeRendererCancel    \
  1130.     Q3_METHOD_TYPE('r','d','a','b')
  1131. typedef void (*TQ3XRendererCancelMethod)(
  1132.     TQ3ViewObject            view,
  1133.     void                    *rendererPrivate);
  1134.  
  1135.  
  1136. /******************************************************************************
  1137.  **                                                                             **
  1138.  **                        Renderer DrawContext Methods                         **
  1139.  **                                                                             **
  1140.  *****************************************************************************/
  1141.  
  1142. /*
  1143.  *    kQ3XMethodTypeRendererPush
  1144.  *    TQ3XRendererPushMethod
  1145.  *    
  1146.  *    kQ3XMethodTypeRendererPop
  1147.  *    TQ3XRendererPopMethod
  1148.  *    
  1149.  *    These methods are called whenever the graphics state in the view
  1150.  *    is pushed or popped. The user may isolate state by calling:
  1151.  *    
  1152.  *    Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &red, view);
  1153.  *    Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &blue, view);
  1154.  *    Q3Attribute_Submit(kQ3AttributeTypeSpecularColor, &white, view);
  1155.  *    Q3Box_Submit(&unitBox, view);
  1156.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1157.  *    Q3Push_Submit(view);
  1158.  *        Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &blue, view);
  1159.  *        Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &green, view);
  1160.  *        Q3Box_Submit(&unitBox, view);
  1161.  *    Q3Pop_Submit(view);    
  1162.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1163.  *    Q3Box_Submit(&unitBox, view);
  1164.  *    
  1165.  *    or by submitting a display group which pushes and pops.
  1166.  *    
  1167.  *    If you support RendererPush and RendererPop in your renderer:
  1168.  *        - you must maintain your drawing state as a stack, as well.
  1169.  *        - you will not be updated with the popped state after
  1170.  *            RendererPop is called.
  1171.  *
  1172.  *    If you do not support Push and Pop in your renderer:
  1173.  *        - you may maintain a single copy of the drawing state.
  1174.  *        - you will be updated with changed fields after the view stack is
  1175.  *            popped.
  1176.  *
  1177.  *    A renderer that supports Push and Pop gets called in the following
  1178.  *    sequence (from example above):
  1179.  *    
  1180.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1181.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1182.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1183.  *    RendererUpdateMatrixLocalToWorld(...)
  1184.  *    RendererSubmitGeometryBox(...)
  1185.  *    RendererPush(...)
  1186.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1187.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1188.  *        RendererSubmitGeometryBox(...)
  1189.  *    RendererPop(...)
  1190.  *    RendererUpdateMatrixLocalToWorld(...)
  1191.  *    RendererSubmitGeometryBox(...)
  1192.  *
  1193.  *    A renderer that does not supports Push and Pop gets called in the
  1194.  *    following sequence:
  1195.  *    
  1196.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1197.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1198.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1199.  *    RendererUpdateMatrixLocalToWorld(...)
  1200.  *    RendererSubmitGeometryBox(...)
  1201.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1202.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1203.  *        RendererSubmitGeometryBox(...)
  1204.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1205.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1206.  *    RendererUpdateMatrixLocalToWorld(...)
  1207.  *    RendererSubmitGeometryBox(...)
  1208.  *    
  1209.  */
  1210. #define kQ3XMethodTypeRendererPush    \
  1211.     Q3_METHOD_TYPE('r','d','p','s')
  1212. typedef TQ3Status (*TQ3XRendererPushMethod)(
  1213.     TQ3ViewObject            view,
  1214.     void                    *rendererPrivate);
  1215.  
  1216. #define kQ3XMethodTypeRendererPop    \
  1217.     Q3_METHOD_TYPE('r','d','p','o')
  1218. typedef TQ3Status (*TQ3XRendererPopMethod)(
  1219.     TQ3ViewObject            view,
  1220.     void                    *rendererPrivate);
  1221.  
  1222. /******************************************************************************
  1223.  **                                                                             **
  1224.  **                            Renderer Cull Methods                             **
  1225.  **                                                                             **
  1226.  *****************************************************************************/
  1227. /*
  1228.  *    kQ3XMethodTypeRendererIsBoundingBoxVisible
  1229.  *    TQ3XRendererIsBoundingBoxVisibleMethod
  1230.  *    
  1231.  *    This method is called to cull complex groups and geometries 
  1232.  *    given their bounding box in local space.
  1233.  *    
  1234.  *    It should transform the local-space bounding box coordinates to
  1235.  *    frustum space and return a TQ3Boolean return value indicating
  1236.  *    whether the box appears within the viewing frustum.
  1237.  *    
  1238.  *    If no method is supplied, the default behvaiour is to return
  1239.  *    kQ3True.
  1240.  *    
  1241.  *    TODO: Default to cull to { (-1,1), (-1,1), (0,1) } frustum?
  1242.  */
  1243. #define kQ3XMethodTypeRendererIsBoundingBoxVisible    \
  1244.     Q3_METHOD_TYPE('r','d','b','x')
  1245. typedef TQ3Boolean (*TQ3XRendererIsBoundingBoxVisibleMethod)(
  1246.     TQ3ViewObject            view,
  1247.     void                    *rendererPrivate,
  1248.     const TQ3BoundingBox    *bBox);
  1249.  
  1250. #if defined(ESCHER_VER_FUTURE) && ESCHER_VER_FUTURE
  1251.  
  1252. /******************************************************************************
  1253.  **                                                                             **
  1254.  **                            Renderer Cache Methods                             **
  1255.  **                                                                             **
  1256.  *****************************************************************************/
  1257.  
  1258. /*
  1259.  *    kQ3XMethodTypeRendererStartCache
  1260.  *    TQ3XRendererStartCacheMethod
  1261.  *    
  1262.  *    The start cache method is called at Q3View_StartRendererCache and
  1263.  *    signals that the application wishes to bracket some information
  1264.  *    that is static within a scene.
  1265.  *    
  1266.  *    If rendererCache is NULL, then the renderer should prepare to cache
  1267.  *    all information until the EndCache method is called.
  1268.  *    
  1269.  *    If rendererCache is non-NULL, then the renderer should validate the
  1270.  *    pre-existing cache.
  1271.  *    
  1272.  *    If the cache is invalid, the call should return kQ3True (meaning
  1273.  *    please retraverse the data) and delete the cache. The renderer
  1274.  *    should prepare to cache all submitted information until the EndCache
  1275.  *    method is called.
  1276.  *    
  1277.  *    If the cache is valid, the renderer should apply the cache to its
  1278.  *    state and/or the image, and return kQ3False (don't retraverse the
  1279.  *    data). EndCache will not be called.
  1280.  *    
  1281.  *    If no method is supplied, the default is to return kQ3True.
  1282.  *    
  1283.  *    OPTIONAL
  1284.  */
  1285. #define kQ3XMethodTypeRendererStartCache    \
  1286.     Q3_METHOD_TYPE('r','d','b','c')
  1287. typedef TQ3Boolean (*TQ3XRendererStartCacheMethod)(
  1288.     TQ3ViewObject            view,
  1289.     void                    *rendererPrivate,
  1290.     void                    *rendererCache);
  1291.  
  1292. /*
  1293.  *    kQ3XMethodTypeRendererEndCache
  1294.  *    TQ3XRendererEndCacheMethod
  1295.  *    
  1296.  *    The end cache method is called at Q3View_EndRenderingCache and
  1297.  *    indicates that all cached information has been submitted. It
  1298.  *    returns a pointer to a private data structure containing the
  1299.  *    cached data. EndCache will only be called after StartCache.
  1300.  *
  1301.  *    If NULL is returned, it indicates that the renderer can not
  1302.  *    cache the information.
  1303.  *    
  1304.  *    If no method is supplied, the default is to return NULL.
  1305.  *    
  1306.  *    OPTIONAL
  1307.  */
  1308. #define kQ3XMethodTypeRendererEndCache    \
  1309.     Q3_METHOD_TYPE('r','d','e','c')
  1310. typedef void *(*TQ3XRendererEndCacheMethod)(
  1311.     TQ3ViewObject            view,
  1312.     void                    *rendererPrivate);
  1313.  
  1314. /*
  1315.  *    kQ3XMethodTypeRendererDeleteCache
  1316.  *    TQ3XRendererDeleteCacheMethod
  1317.  *    
  1318.  *    The delete cache method is called on a cache that has been 
  1319.  *    invalidated.
  1320.  *    
  1321.  *    NOTE: When the RendererStartCache method is passed a cache to 
  1322.  *    validate and it returns kQ3True (cache is invalid, please
  1323.  *    retraverse data), this method is NOT called on the invalid cache.
  1324.  *    It is up to the renderer to delete or re-use the cache passed in.
  1325.  *    
  1326.  *    If no method is supplied, caches are assumed to be unsupported, or
  1327.  *    freed by the renderer.
  1328.  *    
  1329.  *    OPTIONAL
  1330.  */
  1331. #define kQ3XMethodTypeRendererDeleteCache \
  1332.     Q3_METHOD_TYPE('r','d','d','c')
  1333. typedef TQ3Status (*TQ3XRendererDeleteCacheMethod)(
  1334.     TQ3RendererObject        renderer,
  1335.     void                    *rendererPrivate,
  1336.     void                    *rendererCache);
  1337.  
  1338. #endif /* ESCHER_VER_FUTURE */
  1339.  
  1340. /******************************************************************************
  1341.  **                                                                             **
  1342.  **                        Renderer Object Support Methods                         **
  1343.  **                                                                             **
  1344.  *****************************************************************************/
  1345.  
  1346. /*
  1347.  *    Drawing methods (Geometry, Camera, Lights)
  1348.  *
  1349.  */
  1350.  
  1351. /*
  1352.  *    Geometry MetaHandler
  1353.  *    
  1354.  *    This metaHandler is required to support 
  1355.  *    
  1356.  *    kQ3GeometryTypeTriangle
  1357.  *    kQ3GeometryTypeLine
  1358.  *    kQ3GeometryTypePoint
  1359.  *    kQ3GeometryTypeMarker
  1360.  *    kQ3GeometryTypePixmapMarker
  1361.  *    
  1362.  *    REQUIRED
  1363.  */
  1364. #define kQ3XMethodTypeRendererSubmitGeometryMetaHandler    \
  1365.     Q3_METHOD_TYPE('r','d','g','m')
  1366. typedef TQ3XFunctionPointer (*TQ3XRendererSubmitGeometryMetaHandlerMethod)(
  1367.     TQ3ObjectType                    geometryType);
  1368. /*
  1369.  *    The TQ3XRendererSubmitGeometryMetaHandlerMethod switches on geometryType
  1370.  *    of kQ3GeometryTypeFoo and returns methods of type:
  1371.  */
  1372. typedef TQ3Status (*TQ3XRendererSubmitGeometryMethod)(
  1373.     TQ3ViewObject                    view,
  1374.     void                            *rendererPrivate,
  1375.     TQ3GeometryObject                geometry,
  1376.     const void                        *publicData);
  1377.  
  1378.  
  1379. /*
  1380.  *    Camera MetaHandler
  1381.  *    
  1382.  *    This metaHandler, if supplied, indicates that your renderer
  1383.  *    handles deferred transformation of the main camera within a scene.
  1384.  *    
  1385.  *    If not supplied, or an unsupported camera is used, the view will do
  1386.  *    the transformation for the renderer and pass in a camera in the 
  1387.  *    StartPass method.
  1388.  *    
  1389.  *    OPTIONAL
  1390.  */
  1391. #define kQ3XMethodTypeRendererSubmitCameraMetaHandler    \
  1392.     Q3_METHOD_TYPE('r','d','c','m')
  1393. typedef TQ3XFunctionPointer (*TQ3XRendererSubmitCameraMetaHandlerMethod)(
  1394.     TQ3ObjectType                    cameraType);
  1395. /*
  1396.  *    The TQ3XRendererSubmitCameraMetaHandlerMethod switches on cameraType
  1397.  *    of kQ3CameraTypeFoo and returns methods of type:
  1398.  */
  1399. typedef TQ3Status (*TQ3XRendererSubmitCameraMethod)(
  1400.     TQ3ViewObject                    view,
  1401.     void                            *rendererPrivate,
  1402.     TQ3CameraObject                    camera,
  1403.     const void                        *publicData);
  1404.  
  1405.  
  1406. /*
  1407.  *    Light MetaHandler
  1408.  *    
  1409.  *    This metaHandler, if supplied, indicates that your renderer
  1410.  *    handles deferred transformation of lights within a scene.
  1411.  *    
  1412.  *    If an unsupported light is encountered, it is ignored.
  1413.  *
  1414.  *    OPTIONAL
  1415.  */
  1416. #define kQ3XMethodTypeRendererSubmitLightMetaHandler    \
  1417.     Q3_METHOD_TYPE('r','d','l','g')
  1418. typedef TQ3XFunctionPointer (*TQ3XRendererSubmitLightMetaHandlerMethod)(
  1419.     TQ3ObjectType                    lightType);
  1420. /*
  1421.  *    The TQ3XRendererSubmitLightMetaHandlerMethod switches on lightType
  1422.  *    of kQ3LightTypeFoo and returns methods of type:
  1423.  */
  1424. typedef TQ3Status (*TQ3XRendererSubmitLightMethod)(
  1425.     TQ3ViewObject                    view,
  1426.     void                            *rendererPrivate,
  1427.     TQ3LightObject                    light,
  1428.     const void                        *publicData);
  1429.  
  1430. /*
  1431.  *
  1432.  *    Update methods
  1433.  *
  1434.  *    They are called whenever the state has changed. If the renderer supports
  1435.  *    the RendererPush and RendererPop methods, it must maintain its own state
  1436.  *    stack. Updates are not called for changed data when the view stack is
  1437.  *    popped.
  1438.  *
  1439.  *    See the comments for the RendererPush and RendererPop methods above
  1440.  *    for an example of how data is updated.
  1441.  *
  1442.  */
  1443.  
  1444. /*
  1445.  *    Style
  1446.  */
  1447. #define kQ3XMethodTypeRendererUpdateStyleMetaHandler        \
  1448.     Q3_METHOD_TYPE('r','d','y','u')
  1449. typedef TQ3XFunctionPointer (*TQ3XRendererUpdateStyleMetaHandlerMethod)(
  1450.     TQ3ObjectType                    styleType);
  1451. /*
  1452.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on styleType
  1453.  *    of kQ3StyleTypeFoo and returns methods of type:
  1454.  */
  1455. typedef TQ3Status (*TQ3XRendererUpdateStyleMethod)(
  1456.     TQ3ViewObject                    view,
  1457.     void                            *rendererPrivate,
  1458.     const void                        *publicData);
  1459.  
  1460. /*
  1461.  *    Attributes
  1462.  */
  1463. #define kQ3XMethodTypeRendererUpdateAttributeMetaHandler    \
  1464.     Q3_METHOD_TYPE('r','d','a','u')
  1465. typedef TQ3XFunctionPointer (*TQ3XRendererUpdateAttributeMetaHandlerMethod)(
  1466.     TQ3AttributeType                attributeType);
  1467. /*
  1468.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on attributeType
  1469.  *    of kQ3AttributeTypeFoo and returns methods of type:
  1470.  */
  1471. typedef TQ3Status (*TQ3XRendererUpdateAttributeMethod)(
  1472.     TQ3ViewObject                    view,
  1473.     void                            *rendererPrivate,
  1474.     const void                        *publicData);
  1475.  
  1476. /*
  1477.  *    Shaders
  1478.  */
  1479. #define kQ3XMethodTypeRendererUpdateShaderMetaHandler    \
  1480.     Q3_METHOD_TYPE('r','d','s','u')
  1481. typedef TQ3XFunctionPointer (*TQ3XRendererUpdateShaderMetaHandlerMethod)(
  1482.     TQ3ObjectType                    shaderType);
  1483.     
  1484. /*
  1485.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on shaderType
  1486.  *    of kQ3ShaderTypeFoo and returns methods of type:
  1487.  */
  1488. typedef TQ3Status (*TQ3XRendererUpdateShaderMethod)(
  1489.     TQ3ViewObject                    view,
  1490.     void                            *rendererPrivate,
  1491.     TQ3Object                        shaderObject);
  1492.  
  1493. /*
  1494.  *    Matrices
  1495.  */
  1496. #define kQ3XMethodTypeRendererUpdateMatrixMetaHandler                    \
  1497.     Q3_METHOD_TYPE('r','d','x','u')
  1498. typedef TQ3XMetaHandler TQ3XRendererUpdateMatrixMetaHandlerMethod;
  1499.  
  1500. /*
  1501.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on methods
  1502.  *    of the form kQ3MethodTypeRendererUpdateMatrixFoo:
  1503.  */
  1504. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorld                    \
  1505.     Q3_METHOD_TYPE('u','l','w','x')
  1506. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverse            \
  1507.     Q3_METHOD_TYPE('u','l','w','i')
  1508. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverseTranspose    \
  1509.     Q3_METHOD_TYPE('u','l','w','t')
  1510. #define kQ3XMethodTypeRendererUpdateMatrixLocalToCamera                    \
  1511.     Q3_METHOD_TYPE('u','l','c','x')
  1512. #define kQ3XMethodTypeRendererUpdateMatrixLocalToFrustum                \
  1513.     Q3_METHOD_TYPE('u','l','f','x')
  1514. #define kQ3XMethodTypeRendererUpdateMatrixWorldToFrustum                \
  1515.     Q3_METHOD_TYPE('u','w','f','x')
  1516.  
  1517. /*
  1518.  *    and returns methods of type:
  1519.  */
  1520. typedef TQ3Status (*TQ3XRendererUpdateMatrixMethod)(
  1521.     TQ3ViewObject                    view,
  1522.     void                            *rendererPrivate,
  1523.     const TQ3Matrix4x4                *matrix);
  1524.  
  1525. #ifdef __cplusplus
  1526. }
  1527. #endif    /* __cplusplus */
  1528.  
  1529. #if defined(__MWERKS__)
  1530.     #pragma enumsalwaysint reset
  1531. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  1532.     #pragma options enum=reset
  1533. #endif
  1534.  
  1535. #endif  /*  QD3DRenderer_h  */
  1536.